package cn.csc.module.shop.api.detail;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.module.shop.api.detail.dto.ShopDetailRelateReqDTO;
import cn.csc.module.shop.api.detail.dto.ShopDetailRespDTO;
import cn.csc.module.shop.api.detail.dto.UpdateShopTypeReqDTO;
import cn.csc.module.shop.convert.detail.ShopDetailConvert;
import cn.csc.module.shop.service.detail.ShopDetailService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.List;

import static cn.csc.framework.common.pojo.CommonResult.success;

/**
 * 店铺详情 API 实现类
 * Author: liuchuang
 * Date: 2024/1/13
 * Time: 09:57
 * Declaration: All Rights Reserved !!!
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class ShopDetailApiImpl implements ShopDetailApi{

    @Resource
    private ShopDetailService shopDetailService;


    @Override
    public CommonResult<ShopDetailRespDTO> getShopDetail(BigInteger shopId) {
        return success(ShopDetailConvert.INSTANCE.convert2(shopDetailService.getDetail(shopId)));
    }


    /**
     * 通过店铺编号列表获得店铺详情
     *
     * @param shopIds 店铺编号列表
     * @return 店铺详情list
     */
    @Override
    public CommonResult<List<ShopDetailRespDTO>> getShopDetailList(List<BigInteger> shopIds) {
        return success(ShopDetailConvert.INSTANCE.convertList03(shopDetailService.getShopDetailList(shopIds)));
    }

    @Override
    public CommonResult<Boolean> relateShopDetail(ShopDetailRelateReqDTO reqDTO) {
        return success(shopDetailService.relateShopDetail(reqDTO));
    }

    /**
     * 更新店铺类型
     * @param reqDTO
     * @return
     */
    @Override
    public CommonResult<Boolean> updateShopType(UpdateShopTypeReqDTO reqDTO) {
        return success(shopDetailService.updateShopType(reqDTO));
    }
}
